<template>
    <router-view v-slot="{ Component, route }">
      <keep-alive>
        <component :is="Component" v-if="route.meta && route.meta.keepAlive" :key="route.meta.usePathKey ? route.fullPath : undefined" />
      </keep-alive>
      <component :is="Component" v-if="!(route.meta && route.meta.keepAlive)" :key="route.meta.usePathKey ? route.fullPath : undefined" />
    </router-view>
</template>

<script>


// import { ref } from 'vue';
/*<Suspense>
    <template #default>
      <keep-alive>
        <router-view v-if="$route.meta.keepAlive"></router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
    </template>
    <template #fallback> Loading... </template>
  </Suspense>
  <router-view />*/
// <keep-alive>
//   <router-view v-if="$route.meta.keepAlive"></router-view>
// </keep-alive>
// <router-view v-if="!$route.meta.keepAlive"></router-view>
export default {
  name: 'App',
  setup() {
  //   const rate = ref(4);
  //   const slider = ref(50);
  //
  //   // themeVars 内的值会被转换成对应 CSS 变量
  //   // 比如 sliderBarHeight 会转换成 `--van-slider-bar-height`
  //   const themeVars = {
  //     rateIconFullColor: '#07c160',
  //     sliderBarHeight: '4px',
  //     sliderButtonWidth: '20px',
  //     sliderButtonHeight: '20px',
  //     sliderActiveBackgroundColor: '#07c160',
  //     buttonPrimaryBorderColor: '#07c160',
  //     buttonPrimaryBackgroundColor: '#07c160',
  //   };
  //
  //   return {
  //     rate,
  //     slider,
  //     themeVars,
  //   };
    /*onBeforeMount(() => {
      // 在组件挂载之前执行的逻辑
      (function() {
        if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
          handleFontSize();
        } else {
          if (document.addEventListener) {
            document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
          } else if (document.attachEvent) {
            document.attachEvent("WeixinJSBridgeReady", handleFontSize);
            document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
          }
        }
        function handleFontSize() {
          // 设置网页字体为默认大小
          WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
          // 重写设置网页字体大小的事件
          WeixinJSBridge.on('menu:setfont', function() {
            WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
          });
        }
      })();
    });*/
  },

  watch: {
    $route(to) {
      document.title = to.meta?.title || '教务系统';
    }
  }
}
</script>

<style scoped>

</style>
